home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / close.man < prev    next >
Encoding:
Text File  |  1989-01-08  |  2.4 KB  |  67 lines

  1.  
  2.  
  3.  
  4. CLOSE                 C Library Procedures                  CLOSE
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      close - delete a descriptor
  10.  
  11. SSYYNNOOPPSSIISS
  12.      cclloossee((dd))
  13.      iinntt dd;;
  14.  
  15. DDEESSCCRRIIPPTTIIOONN
  16.      The _c_l_o_s_e call deletes a descriptor from the per-process
  17.      object reference table.  If this is the last reference to
  18.      the underlying object, then it will be deactivated.  For
  19.      example, on the last close of a file the current _s_e_e_k
  20.      pointer associated with the file is lost; on the last close
  21.      of a _s_o_c_k_e_t(2) associated naming information and queued data
  22.      are discarded; on the last close of a file holding an
  23.      advisory lock the lock is released (see further _f_l_o_c_k(2)).
  24.  
  25.      A close of all of a process's descriptors is automatic on
  26.      _e_x_i_t, but since there is a limit on the number of active
  27.      descriptors per process, _c_l_o_s_e is necessary for programs
  28.      that deal with many descriptors.
  29.  
  30.      When a process forks (see _f_o_r_k(2)), all descriptors for the
  31.      new child process reference the same objects as they did in
  32.      the parent before the fork.  If a new process is then to be
  33.      run using _e_x_e_c_v_e(2), the process would normally inherit
  34.      these descriptors.  Most of the descriptors can be rear-
  35.      ranged with _d_u_p_2(2) or deleted with _c_l_o_s_e before the _e_x_e_c_v_e
  36.      is attempted, but if some of these descriptors will still be
  37.      needed if the execve fails, it is necessary to arrange for
  38.      them to be closed if the execve succeeds.  For this reason,
  39.      the call ``fcntl(d, F_SETFD, 1)'' is provided, which
  40.      arranges that a descriptor will be closed after a successful
  41.      execve; the call ``fcntl(d, F_SETFD, 0)'' restores the
  42.      default, which is to not close the descriptor.
  43.  
  44. RREETTUURRNN VVAALLUUEE
  45.      Upon successful completion, a value of 0 is returned.  Oth-
  46.      erwise, a value of -1 is returned and the global integer
  47.      variable _e_r_r_n_o is set to indicate the error.
  48.  
  49. EERRRROORRSS
  50.      _C_l_o_s_e will fail if:
  51.  
  52.      [EBADF]        _D is not an active descriptor.
  53.  
  54. SSEEEE AALLSSOO
  55.      accept(2), flock(2), open(2), pipe(2), socket(2), socket-
  56.      pair(2), execve(2), fcntl(2)
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 22, 1986                          1
  64.  
  65.  
  66.  
  67.